package org.example.DesignPatterns.Mediator;

/**
 * @description:
 * @author: farprt
 * @create: 2022-09-24 08:58
 **/
public class Client {

    public static void main(String[] args) {
        ChatRoom chatRoom=new PublicChatRoom("设计模式");

        User user1=new User("张三");
        User user2=new User("李四");
        User user3=new User("王五");

        user1.login(chatRoom);
        user2.login(chatRoom);

        user1.talk(user2,"hello");

        user2.talk(user1,"hello");

        user3.login(chatRoom);
        user3.talk(user1,"hello world");
        user3.talk(null,"helloworld");
        user1.logout();
        user2.logout();
        user3.logout();

        chatRoom=new PrivateChatRoom("私人聊天室");
        user1.login(chatRoom);
        user1.talk(user2,"hello");
        user2.login(chatRoom);
        user2.talk(user1,"hello");

        user3.login(chatRoom);
        user3.talk(null,"rua");
    }
}